<template>
	<view class="bgColor-white">
		<view class="px-30 border-b">
			<x-card-strip :border='false' leftText="选择快递公司" @cardEvent='this.$refs.erweima.show()'
				:rightText='reasonText'></x-card-strip>
		</view>
		<popup ref='erweima' type='bottom' radius='6' height='660' centerAnim='slide-up' :showCloseIcon='true'
			:maskClickClose='false' :duration='300'>
			<view class="pg-30 mt-30 d-flex flex-d">
				<text @tap='reasonText=item.express_title;addID=item.express_code;$refs.erweima.hide()'
					class="d-inline-block py-20 border-b" v-for="(item,index) in addArr"
					:key='index'>{{item.express_title}}</text>
			</view>
		</popup>
		<view class="pg-30 border-b">
			<view>商家地址</view>
			<view class="textColor999 font-24 mt-10" style="line-height: 40rpx;">
				{{text}}
				<view style="text-align: right;">
					<text @tap="ctrl_c" style="border: 1px solid #ddd; padding: 0 10rpx;"
						class="border-rs-1 d-inline-block ml-20  color-999 font-24">复制</text>
				</view>
			</view>
		</view>
		<view class="pg-30 d-flex-yCenter border-b">
			<text>快递单号</text>
			<input class="ml-20" type="text" placeholder="请输入快递单号" v-model="value" />
		</view>
		<view class="pg-30" style="background: #ddd;">
			<x-button title="提交" @btnClick='submit'></x-button>
		</view>
	</view>
</template>

<script>
	import {
		http_user_order_refund_express_company,
		http_user_order_refund_send_out_goods
	} from '@/config/apiRouter.js'
	import popup from '@/components/wyb-popup/wyb-popup.vue'
	export default {
		components: {
			popup
		},
		data() {
			return {
				reasonText: '请选择',
				text: '',
				addID: '',
				value: '',
				addArr: []
			}
		},
		onLoad(opens) {
			let data = JSON.parse(opens.data)
			this.data = data
			this.text = `${data.express_province} ${data.express_city} ${data.express_area} ${data.express_address}
								收货人：${data.express_name}, 电话：${data.express_phone} `
			http_user_order_refund_express_company({
				data: {
					order_no: data.order_no
				}
			}).then(res => {
				console.log(res);
				this.addArr = res.data
			})
		},
		methods: {
			ctrl_c() {
				uni.setClipboardData({
					data: this.text,
					success(res) {
						uni.showToast({
							title: '复制成功',
						})
					}
				});
			},
			submit() {
				if (this.addID == '') {
					this.$tool.showToast('请选择快递公司')
					return
				}
				if (this.value.trim() == '') {
					this.$tool.showToast('请输入快递单号')
					return
				}
				var data = {
					refund_order_no: this.data.refund_order_no,
					express_send_no: this.value,
					express_company_code: this.addID
				}
				http_user_order_refund_send_out_goods({
					data
				}).then(res=>{
					uni.showModal({
						title:'退款提示',
						content:'退货信息提交成功，商家将在收到货后进行售后处理',
						showCancel:false,
						success:()=>{
							this.$tool.navigateBack()
						}
					})
				})
				console.log(data);
			}
		}
	}
</script>

<style>
	page {
		background: #ddd;
	}
</style>
